window._TM = {


  testTaskErr:function(){
      for(var i=0;i<10000;i++)
      for(var key in _MAINTASK){

        var result = _MXYT.getNpcRewardOfTask(_MAINTASK[key]);

        if(!result.value)
          console.log(key,result)
      }


  },

  testPreMap:function(){

    for(var key in _MAPCONFIG){
      var mapConf = _MAPCONFIG[key];
      if(mapConf.premap){
        for(var i=0;i<mapConf.premap.length;i++){
          var premap = mapConf.premap[i];
          if(!_MAPCONFIG[premap]){
            console.log(key,premap,"不存在");
          }
        }
      }

    }

  },

  getRoleToTeam:function(role){
    window.gameData.playerTeamBack.unshift(_CROF.getRandomMainRole(false,role))
  },

  showAllZSSKILL:function(){
    for(var key in _SKILLBD){
      if(_SKILLBD[key].noshop){
        console.log(key);
      }
    }
    console.log("##############");
    for(var key in _SKILL){
      if(_SKILL[key].noshop){
        console.log(key);
      }
    }
  },

  testXwAttr:function(){
    var xwattrmap = {};
    for(var key in _XW){

      var xwConfig = _XW[key];
      if(xwattrmap[xwConfig.attr]){
        xwattrmap[xwConfig.attr]+=","+key+":'SS'"
      }else{
        xwattrmap[xwConfig.attr]=key+":'SS'"
      }

    }

    console.log(xwattrmap);
  },

  getNpc:function(npc){
    window.gameData.playerTeamBack.unshift(_CROF.getRandomMainRole(false,npc,null));
  },
  
  isXwCf:function(xw1,xw2){
    for(var key in xw1){
      if(xw1[key]!=xw2[key]){
        return false;
      }
    }

    for(var key in xw2){
      if(xw1[key]!=xw2[key]){
        return false;
      }
    }

    return true;
  },

  //检测人物修为是否有重复
  testSameXw:function(){

    var samemap = {};

    for(var key in _NPC){
      var npca = _NPC[key];
      if(npca.level!='D'){
        for(var key2 in _NPC){
          var npcb = _NPC[key2];
          if(npca.npcxw&&npcb.npcxw){
            if(_TM.isXwCf(npca.npcxw,npcb.npcxw)&&key!=key2&&!samemap[key+"-"+key2]&&npca.race==npcb.race){
              console.log('修为重复:',key,key2);
              samemap[key+"-"+key2]=1;
              samemap[key2+"-"+key]=1;
            }
          }else{
            //console.log('修为不存在',key,key2);
          }
        }
      }

    }


  },

  //测试职业修为融合
  testRaceXwNmb:function(){

    var racemap = {yao:{},xian:{},ren:{}};

    for(var key in _NPC){

      var npcconf = _NPC[key];
      var npcxw = npcconf.npcxw;
      var maxxw = _RHM.getMaxXwObj(npcxw);
      if(maxxw){
        var xw = maxxw.xw;
        var level = maxxw.level;
        var race = npcconf.race;
        if(level!=npcconf.level){
          console.log('修为和评级不匹配',key);
        }

        if(racemap[race]){
          if(racemap[race][xw]){
            if(racemap[race][xw][level]){
              racemap[race][xw][level]++;
            }else{
              racemap[race][xw][level]=1;
            }
          }else{
            racemap[race][xw]={};
            racemap[race][xw][level]=1;
          }
        }
      }else{
        console.log('无法找到最高修为:',key);
      }
    }

    console.log(racemap);
    for(var key in racemap){

      var racearr = [];

      var tmap = racemap[key];

      for(var xw in _XW){
        if(!tmap[xw]){
          racearr.push(xw);
        }
      }

      
      console.log("缺少修为",key,racearr);

    }

  },


  //测试职业修为分布
  testJobXw:function(){

    var jobmap = {};
    //var dmap = {};
    var allattr = {};
    var allxw = {};
    var npcxw ={};
    var jobxw = "";

    for(var attr in _DICT){
      allattr[attr]=1;
    }

    for(var xw in _XW){
      allxw[xw] = 1;
    }

    for(var key in window._SKILLCOMBINE){

        jobmap[key]={};
        npcxw[key]={};

        var attrObj = {};

        for(var skillname in window._SKILLCOMBINE[key]['被动']){
          var skillconf = _SKILLBD[skillname];
          for(var xw in skillconf.xw){
            jobmap[key][xw]=1;
            allxw[xw]=0;
          }
          for(var attr in skillconf.attr){
            allattr[attr]=0;
            if(!attrObj[attr]){
              attrObj[attr]=skillconf.attr[attr]
            }else{
              attrObj[attr]+=skillconf.attr[attr];
            }
          }

        }

        for(var skillname in window._SKILLCOMBINE[key]['主动']){

          var skillconf = _SKILL[skillname];
          for(var xw in skillconf.xw){
            jobmap[key][xw]=1;
            allxw[xw]=0;
          }

        }

        for(var xw in window._SKILLCOMBINE[key]['修为']){
          if(!_XW[xw]){
            console.log(key,xw,'不存在');
          }
        }
        
        for(var name in window._SKILLCOMBINE[key]['角色']){
          var conf = _SKILLCOMBINE[key]['角色'][name];
          for(var xw in conf.npcxw){
            npcxw[key][xw]=1;
          }
        }

        console.log(key,attrObj);

        //dmap[key]=dnmb;
        
    }

    console.log(jobmap);

    for(var key in jobmap){
      var arr = [];
      var arr1=[];
      var arr2=[];
      var arr4=[];
      for(var xw in jobmap[key]){
        arr.push(_XW[xw].label);
        if(_XWT._RACE[xw]){
          arr2.push(_XW[xw].label);
        }else{
          arr1.push(_XW[xw].label);
        }
        arr4.push(xw+":'D'");
      }
      //console.log(key,arr);
     
      jobxw+=key+":["+arr1.join(",")+"],["+arr2.join(",")+"]\n";

      jobxw+=arr4.join(",")+"\n\n";

    }
    console.log(allxw,allattr);
    console.log(jobxw);
    console.log(npcxw);
    //console.log(dmap);
  },

  testJobNmb:function(){

    var jobmap = {};
    for(var key in _NPC){
      var job = _NPC[key].job;
      if(jobmap[job]){
        jobmap[job]++;
      }else{
        jobmap[job]=1;
      }
    }
    console.log(jobmap);
  },

  testAllConfigXy:function(){

    console.log("#############检测任务");
    _TM.testTask();

    console.log("###############检测前置地图");
    _TM.testPreMap();

    console.log("#############检测地图");
    _TM.testMapNpc();

    console.log("#############检测人物修为");
    _TM.testNpcXw();

    console.log("#############检测技能动画");
    _TM.testSkillAni();

    console.log("#############检测人物技能");
    _TM.testNpcSkill();

    console.log("#############检测技能描述");
    _TM.testSkill();
  },

  testMainTask:function(){
    var index = 0;
    var bossMap = {};
    var xwMap = {};
    var npcMap ={};

    var bossArr = [];
    var xwArr = [];
    var npcArr =[];

    for(var key in _NPC){
      var npcconf = _NPC[key];
      if(npcconf.level!="D"
            &&npcconf.level!="C")
      bossArr.push({type:key,lv:_NPC[key].level});
    }
    
    for(var key in _MAINTASK){
      var taskConf = _MAINTASK[key];
      if(!taskConf.isselect){
        index++;
        var map = taskConf.map;
        var mapconf = _NPCMAP[map];
        var lv = mapconf.lv;
        var npc = mapconf.npc;
        for(var i=0;i<npc.length;i++){
          var npctype = npc[i].npc;
          var npcconf = _NPC[npctype];
          if(npcconf.level=="D"
            ||npcconf.level=="C"
          ){
            if(!npcMap[npctype]){
              npcMap[npctype]=1;
              npcArr.push({type:npctype,lv:lv});
            }
          }
          //console.log(npcconf.xw);
          for(var xw in npcconf.npcxw){
            if(!xwMap[xw]){
              xwMap[xw]=1;
              xwArr.push({type:xw,lv:lv});
            }
          }
        }
      }
    }

    bossArr.sort((a, b) => {
      var lva = _TM.getqua(a.lv);
      var lvb = _TM.getqua(b.lv);
      return lva - lvb;
    });

    console.log(index);
    console.log(npcArr);
    console.log(bossArr);
    console.log(xwArr);
  },

  getqua:function(qua){
    if(qua=="D"){
      return 1;
    }else if(qua=="C"){
      return 2;
    }else if(qua=="B"){
      return 3;
    }else if(qua=="A"){
      return 4;
    }else if(qua=="S"){
      return 5;
    }else if(qua=="SS"){
      return 6;
    }
  },

  testTask:function(){

    var taskMap = {};

    for(var key in _MAINTASK){

      var taskConf = _MAINTASK[key];
      var nexttask = taskConf.nexttask;
      var detail= taskConf.detail;
      for(var j=0;j<nexttask.length;j++){
        if(!_MAINTASK[nexttask[j]]){
          console.log(nexttask[j],'不存在');
        }
      }

      for(var j=0;j<detail.length;j++){
        var npc = detail[j].target;
        if(!_NPC[npc]){
          console.log(npc,'不存在');
        }
      }

      taskMap[taskConf.map]=1;

    }
    
    for(var key in _MAPCONFIG){
      if(_MAPCONFIG[key].isRoot&&!taskMap[key]&&!_MAPCONFIG[key].premap){
        console.log(key,'没有解锁');
      }
    }

  },


  testMapNpc:function(){

    for(var key in _MAINTASK){

      var taskconfig = _MAINTASK[key];
      var taskname = taskconfig.taskname;
      var target = taskconfig.detail;

      for(var i=0;i<target.length;i++){

        var npc = target[i].target;

        if(!_NPC[npc]){

          console.log(taskname,npc,"怪物缺失");

        }else {

          var live = false;

          for(var mapname in _NPCMAP){

            var npcarr = _NPCMAP[mapname].npc;
            for(var j=0;j<npcarr.length;j++){

              if(npcarr[j].npc == npc){

                live = true;

                if(_MAPCONFIG[mapname]){

                }else{

                  console.log(taskname,npc,mapname,"怪物所在地图缺失");

                }

                break;
              }

            }

          }

          if(!live){
            console.log(taskname,npc,"怪物不存在于地图中");
          }

        }

      }


    }

    /*
    console.log("##########验证地图1");
    for(var key in _MAPCONFIG){
      if(!_NPCMAP[key]){
        console.log(key,'不存在');
      } 
    }

    console.log("##############验证地图2");
    for(var key in _NPCMAP){
      if(!_MAPCONFIG[key]){
        console.log(key,'不存在');
      } 
    }
    */


    console.log("#############验证地图小怪");
    for(var key in _NPCMAP){

      var npcarr = _NPCMAP[key].npc;
      for(var i=0;i<npcarr.length;i++){
        if(!_NPC[npcarr[i].npc]){
          console.log(key,npcarr[i],'不存在');
        }
      }

    }


  },


  testNpcXw:function(){

    var temp = {};

    for(var key in _NPC){

      if(!_NPC[key].ftype
        ||(
          _NPC[key].ftype!='金'
          &&_NPC[key].ftype!='木'
          &&_NPC[key].ftype!='水'
          &&_NPC[key].ftype!='火'
          &&_NPC[key].ftype!='土'
        )
      ){
        console.log(key,'五行异常');
      }

      for(var xw in _NPC[key].npcxw){

        if(!_XW[xw]){

          if(!temp[xw]){
            temp[xw]=1;
            console.log(key,xw,'不存在');
          }

        }

      }

    }

  },

  testArmyAutoConfig:function(){

    var chapterlv = [1,50,100,200,300,400,500,600,700,800,900,1000];

    for(var key in _JOB){
      console.log(key+"################");
      for(var i=0;i<chapterlv.length;i++){
        var role = _CROF.createJobRole(key,{dzlevel:0,lv:1,chapterLv:chapterlv[i],jobPath:null,chapter:null});
        console.log(chapterlv[i],role.equip,role.skill);
      }

    }

  },

  testSkillAni:function(){

    var animap = {};

    for(var key in _GRM.skillAni){

      animap[key]=1;

    }

    for(var key in _SKILL){

      if(animap[_SKILL[key].ani]){
        animap[_SKILL[key].ani]++;
      }else{
        console.log(key,_SKILL[key].ani,'不存在');
      }

      if(
        (_SKILL[key].ani=="huo_dan"&&_SKILL[key].ftype!='火')
        ||(_SKILL[key].ani=="mu_dan"&&_SKILL[key].ftype!='木')
        ||(_SKILL[key].ani=="shui_dan"&&_SKILL[key].ftype!='水')
        ||(_SKILL[key].ani=="jin_dan"&&_SKILL[key].ftype!='金')
        ||(_SKILL[key].ani=="tu_dan"&&_SKILL[key].ftype!='土')
        ||(_SKILL[key].ani!="huo_dan"&&_SKILL[key].ftype=='火')
        ||(_SKILL[key].ani!="mu_dan"&&_SKILL[key].ftype=='木')
        ||(_SKILL[key].ani!="jin_dan"&&_SKILL[key].ftype=='金')
        ||(_SKILL[key].ani!="tu_dan"&&_SKILL[key].ftype=='土')
        ||(_SKILL[key].ani!="shui_dan"&&_SKILL[key].ftype=='水')
      ){
        console.log(key,_SKILL[key].ani,_SKILL[key].ftype,'五行动画对不上');
      }

    }

    console.log(animap);
  },
  
  testNpcSkill:function(){

    for(var key in _NPC){

      if(_NPC[key]&&_NPC[key].skill){
        for(var i=0;i<_NPC[key].skill.length;i++){
            var skillname = _NPC[key].skill[i];
            if(
              !_SKILLBD[skillname]
              &&!_SKILL[skillname]
            ){
              console.log(key,skillname,"不存在");
            }

        }
      }

    }

  },


  testTaskReward:function(){

    var total = {};
    var levelobj = {};

    for(var i=0;i<_MAINTASK.length;i++){

      var taskconf = _MAINTASK[i];
      var reward = _TASKREWARD[taskconf.level];

      if(levelobj[taskconf.level]){
        levelobj[taskconf.level]++;
      }else{
        levelobj[taskconf.level]=1;
      }

      if(reward){
        for(var j=0;j<reward.length;j++){
          if(total[reward[j].type]){
            total[reward[j].type]+=reward[j].nmb;
          }else{
            total[reward[j].type]=reward[j].nmb;
          }
        }
      }else{
        console.log(i,'没有奖励');
      }

    }

    console.log(levelobj);

    return total;
  },

  testSkill:function(){

    for(var key in _SKILL){

      var skillconf = _SKILL[key];

      var cut = skillconf.cut;
      var des = skillconf.des;
      var desarr = des.split("消耗:");
      if(desarr.length>1){
        desarr = desarr[1].split("]");
        if(desarr.length>0){
          if((cut+"灯")!=desarr[0]){
            console.log(key,cut,desarr[0]);
          }
        }
      }

      if(skillconf.xw){
      for(var xw in skillconf.xw){
        if(!_XW[xw]){
          console.log('修为异常:',xw,key);
        }
      }
      }else{
        console.log('未配置修为',key);
      }


      if(skillconf.npc&&skillconf.npc!='self'&&!_NPC[skillconf.npc]){
        console.log(key,skillconf.npc,"召唤兽不存在");
      }

      if(skillconf.animals&&!_ANIMALS[skillconf.animals]){
        console.log(key,skillconf.animals,"变身不存在");
      }

      if(skillconf.targeteg){
        console.log("###############",key,skillconf.targeteg);
      }
    }

  },

  searchSkillbd(fsx){

    //var fsx = _ME.getFSXsearchKey(keyword);
    var arr = [];
    var result = "";
    for(var key in _SKILLBD){
      if(
        _SKILLBD[key].attr&&_SKILLBD[key].attr[fsx]
        //&&!_SKILLBD[key].bossflag
      ){
        //result+=key+","
        arr.push({name:key,value:_SKILLBD[key].attr[fsx]});
      }
    }

    arr.sort((a, b) => {
      var lva = a.value;
      var lvb = b.value;
      return lva - lvb;
    });

    for(var i=0;i<arr.length;i++){
      result+=arr[i].name+"("+arr[i].value+"),";
    }

    return result;
  },


  testBossOrder:function(){
    var index = 0;
    for(var key in _CMAP){

      var chapterConf = _CMAP[key];

      var taskConf = _MAINTASK[index];

      var fightlv = taskConf.target.chapterIndex;

      for(var i=0;i<fightlv;i++){

        var boss = _CU.getArrObjByOrder(i,_CMAP[key].boss);

        if(boss){
          

          //计算锻造数
          var dzlevel = chapterConf.elevel+Math.floor(fightlv);

          var chapterLv = fightlv>_CS.maxxw?999:fightlv;

          var bossdzlevel = dzlevel*2;

          var armyLv = chapterConf.level+fightlv;
          if(armyLv>1000){
              armyLv=1000;
          }

          var bosslv = (armyLv*2>1000)?1000:armyLv*2;

          var role = _CROF.createNpcRole(boss,{dzlevel:bossdzlevel,lv:bosslv,chapterLv:chapterLv,chapter:key});
          var player = _ROLEDATA.getRoleDataOfPlayer(role);
          var fightData = _TM.testFightData(player);

          console.log(key,i,boss,_CU.getUnitNmb(fightData));

        }

      }


      index++;

      console.log("##########################################");
    }

  },


  //'大魔王':{qua:'SS',img:'神祇',attr:{maxHp:1000000000,speed:300,hitEnergy:100,gedang:100,miss:100,damageReduce:100,poge:1,missEnergy:100},xw:{sq:9999},bossflag:'11级BOSS专用'},
  createSkillBdForChapter:function(){

      var data = [
        200,
        2000,4000,6000,8000,10000,//2000
        15000,20000,25000,30000,50000,//5000
        60000,70000,80000,90000,100000,//10000
        150000,200000,250000,300000,400000,//50000
        500000,600000,700000,800000,900000,//100000
        1000000,1500000,2000000,2500000,3000000,
        4000000,5000000
      ];

      var index =0;
      var str = "";
      for(var key in _CMAP){
        var d = data[index];
        str+='"'+key+'守军":{qua:"SS",img:"神祇",attr:{attack:'+d+',mattack:'+d+',defend:'+d+',mdefend:'+d+'},xw:{sq:9999},bossflag:"敌军专用"},\n';
        index++;
      }

      console.log(str);
  },

  //_TM.testChapterData(true,null,0);
  //hasDetail true--展示详情 false--只看最高战力
  //chapter  null--看全部  XX关--只看XX关
  //hardtype  0--一周目  1--二周目 2--三周目
  //liupai
  //战力查看
  //_TM.testChapterData({hasDetail:true,chapter:'潘西',hardtype:0,attr:'maxHp',showBoss:false,showArmy:true,showSkill:false,liupai:'肉盾'});
  testChapterData:function(param){

    var hasDetail=param.hasDetail;
    var chapter=param.chapter;
    var hardtype=param.hardtype;
    var attr=param.attr;
    var showBoss = param.showBoss;
    var showArmy = param.showArmy;
    var showSkill = param.showSkill;
    var bossliupai = param.liupai;

    window.gameData = {fsbhdlv:hardtype};

    var index = 0;
    for(var key in _CMAP){

      if(!chapter||key==chapter){

        var maxData = 0;

        var maxname = "";

        var chapterConf = _CMAP[key];

        var armyConf = chapterConf.army;

        var bossConf = chapterConf.boss;

        var taskConf = _MAINTASK[index];

        if(taskConf){

          var armyLiupai = chapterConf.liupai;

          var fightlv = taskConf.target.chapterIndex;

          //计算锻造数
          var dzlevel = chapterConf.elevel+Math.floor(fightlv);

          var chapterLv = fightlv>_CS.maxxw?999:fightlv;

          var armyLv = chapterConf.level+fightlv;
          if(armyLv>1000){
              armyLv=1000;
          }

          if(hasDetail){
            //console.log("#############",key,taskConf.target.chapter,"层数",taskConf.target.chapterIndex);
            console.log("#############",key,"层数",taskConf.target.chapterIndex);
          }

          if(showBoss){
            for(var i=0;i<bossConf.length;i++){

              var randomBoss = bossConf[i];
              var randomBossLiupai = _ME.getNpcLiupai(randomBoss);

              if(!bossliupai||randomBossLiupai==bossliupai){

                var bossdzlevel = dzlevel*2;
                var bosslv = (armyLv*2>1000)?1000:armyLv*2;
                var role = _CROF.createNpcRole(randomBoss,{dzlevel:bossdzlevel,lv:bosslv,chapterLv:chapterLv,chapter:key});
                var player = _ROLEDATA.getRoleDataOfPlayer(role);
                var fightData = _TM.testFightData(player);
                if(hasDetail){
                      if(!attr){
                        console.log(
                          randomBoss,
                          _NPC[randomBoss].job+"("+_JOB[_NPC[randomBoss].job].level+")",
                          randomBossLiupai,
                          "战:"+_CU.getUnitNmb(fightData),
                          "攻:"+_CU.getUnitNmb(player.attack),
                          "精:"+_CU.getUnitNmb(player.mattack),
                          "防:"+_CU.getUnitNmb(player.defend),
                          "魔:"+_CU.getUnitNmb(player.mdefend),
                          "血:"+_CU.getUnitNmb(player.maxHp),
                          "蓝:"+_CU.getUnitNmb(player.maxMagic),
                          "速:"+player.speed,
                          "能:"+player.beginEnergy,
                        );
                        if(showSkill){
                          console.log(role.skill);
                        }
                      }else{
                        console.log(
                          randomBoss,
                          _NPC[randomBoss].job+"("+_JOB[_NPC[randomBoss].job].level+")",
                          attr+":"+_CU.getUnitNmb(player[attr])
                        );
                      }
                }
                if(maxData<fightData){
                    maxData=fightData;
                    maxname = randomBoss;
                }
              }
            }
          }

          if(showArmy){
          for(var i=0;i<armyConf.length;i++){
            var tempArmyType = armyConf[i];
            var jobPath = null;
            if(armyLiupai&&armyLiupai[tempArmyType]){
                jobPath=armyLiupai[tempArmyType];
            }
            var role = _CROF.createJobRole(tempArmyType,{dzlevel:dzlevel,lv:armyLv,chapterLv:chapterLv,jobPath:jobPath,chapter:key});
            var player = _ROLEDATA.getRoleDataOfPlayer(role);
            if(hasDetail){
                    

                      if(!attr){
                        console.log(
                          tempArmyType,
                          "战:"+_CU.getUnitNmb(_TM.testFightData(player)),
                          "攻:"+_CU.getUnitNmb(player.attack),
                          "精:"+_CU.getUnitNmb(player.mattack),
                          "防:"+_CU.getUnitNmb(player.defend),
                          "魔:"+_CU.getUnitNmb(player.mdefend),
                          "血:"+_CU.getUnitNmb(player.maxHp),
                          "速:"+player.speed,
                          "能:"+player.beginEnergy,
                          showSkill?role.skill:''
                        );    
                      }else{
                        console.log(
                          tempArmyType,
                          attr+":"+_CU.getUnitNmb(player[attr])
                        );  
                      }
            }

          }

          console.log("#############"+key+"最强战力:",maxname,_CU.getUnitNmb(maxData));
        }
      }
      }

      index++;
    }

  },

  testFightData:function(playerData){

    

    return playerData.attack+playerData.defend+playerData.mattack+playerData.mdefend+playerData.maxHp/10;

  },

  testAdz:function(basegold,dzper){

    if(!dzper){
      dzper=_MDZ._DZGOLDPER;
    }

    console.log('价格增幅:',dzper);

    var totalprice=0;
    //var basegold=1000;
    for(var k=0;k<2000;k++){

      var gold =Math.floor(basegold*Math.pow(dzper,k));
      totalprice+=gold;
      if(k%100==0)
      console.log('锻造:'+k+" 单价:"+_CU.getUnitNmb(gold)+" 累计总价:"+_CU.getUnitNmb(totalprice));
      

    }

  },


  testSkillframe:function(){

    for(var key in _GRM.skillAni){

      var framearr = _GRM.getSkillFrame(key);

      if(framearr.length!=_GRM.skillAni[key].nmb)
      console.log(key,_GRM.getSkillFrame(key));

    }

  },

  createsuipianshop:function(xw){

    var arr = [
      [],
      [],
      [],
      [],
      [],
      [],
      [],
      [],
      [],
      [],
      []
    ];
    for(var key in _NPC){

      var jobConf = _JOB[_NPC[key].job];
      if(jobConf.xw[xw]){
        //console.log(key);
        var index = _NPC[key].level-1;
        arr[index].push(key+'挑战书');
      }
      
    }

    console.log(JSON.stringify(arr));
  },


  createsuipian:function(){

    var conf = [
        {lv:100,qua:'C',cnmb:5},
        {lv:200,qua:'C',cnmb:10},
        {lv:300,qua:'B',cnmb:15},
        {lv:400,qua:'B',cnmb:20},
        {lv:500,qua:'A',cnmb:25},
        {lv:600,qua:'A',cnmb:30},
        {lv:700,qua:'S',cnmb:35},
        {lv:800,qua:'S',cnmb:40},
        {lv:1000,qua:'SS',cnmb:45},
        {lv:1000,qua:'SS',cnmb:50},
        {lv:1000,qua:'SS',cnmb:100}
    ];
    var str = "";
    for(var key in _NPC){

      var tconf = conf[_NPC[key].level-1];
      if(tconf){
        //console.log();
        //str+='"'+key+'挑战书":{skilltype:"bossbook",img:"'+_NPC[key].face+'",boss:"'+key+'",lv:'+tconf.lv+',qua:"'+tconf.qua+'",des:"使用后可以挑战'+key+'"},\n';
        str+='"'+key+'碎片":{skilltype:"bosspart",img:"'+_NPC[key].face+'",boss:"'+key+'",cnmb:'+tconf.cnmb+',lv:'+tconf.lv+',qua:"'+tconf.qua+'",des:"集齐'+tconf.cnmb+'个可以合成'+key+'"},\n'
      }
      //"ATM碎片":{skilltype:"bosspart",img:"atm",boss:'ATM',cnmb:1000,lv:1000,qua:"SS",des:"集齐1000个可以合成ATM"},
    
    }

    console.log(str);
  },

  testAllJobPathSkill:function(){
    for(var key in _JOB){

      console.log(key,_CROF.getSkillOfJobPath(key));

    }
  },
  
  testSkillLevelUp:function(){

    for(var key in _SKILLBD){

      if(_SKILLBD[key].skilltype){

        console.log(key,_MJOB.getNextSkillBd(key));

      }

    }

  },

  addAllNpcData: function () {

    for (var key in _NPC) {
      //var jobObj = _CROF.createJobRole(key, { dz: 100, npcname: key, noRandom: 1, attr: 100, lv: 1000 });

      var npcobj = _CROF.createNpcRole(key,{dzlevel:100,lv:1000})

      window.gameData.playerTeamBack.push(npcobj);
    }

  },


  testAllNpcData: function () {

   for(var chapter in _NPCMAP){

    var lv = _NPCMAP[chapter].lv;
    var dzlevel = _NPCMAP[chapter].elevel;
      for(var i=0;i<_NPCMAP[chapter].npc.length;i++){

        var key = _NPCMAP[chapter].npc[i].npc;

      var npcobj = _MCFC.createNpcRole(key,{dzlevel:dzlevel,lv:lv})

      var jobData = _ROLEDATA.getRoleDataOfPlayer(npcobj);
      console.log(chapter+ "++++"+key + "+++++++++++++++++++");
      console.log(_ROLEDATA.getAttrString(true, jobData));
      //console.log(_ROLEDATA.getAttrString(false, jobData));
      }

   }

  },

  testAllJobData: function () {

    for (var key in _JOB) {
      var jobObj = _CROF.createJobRole(key, { dz: 100, npcname: key, noRandom: 1, attr: 100, lv: 1000 });
      var jobData = _ROLEDATA.getRoleDataOfPlayer(jobObj);
      console.log(key + "+++++++++++++++++++");
      console.log(_ROLEDATA.getAttrString(true, jobData));
      console.log(_ROLEDATA.getAttrString(false, jobData));
    }

  },


  testJobSkill: function () {

    for (var key in _JOB) {

      console.log(key, _CROF.getSkillOfJob(key));

    }

  },

  createSkillShop: function () {

    var result = {
      'C': [],
      'B': [],
      'A': [],
      'S': [],
      'SS': []
    };

    var resultstr = "";

    for (var key in _SKILLBD) {

      if(!_SKILLBD[key].exc){
        if (result[_SKILLBD[key].qua]) {
          result[_SKILLBD[key].qua].push(key);
        } else {
          console.log(key, _SKILLBD[key].qua);
        }
      }
    }

    for (var key in result) {

      resultstr += "['" + result[key].join("','") + "'],\n"

    }

    console.log(resultstr);
  },

  createJobShop: function () {

    var result = {
      '1': [],
      '2': [],
      '3': [],
      '4': [],
      '5': []
    };

    var resultstr = "";

    for (var key in _JOB) {

      if (result[_JOB[key].level]) {
        result[_JOB[key].level].push(key);
      } else {
        console.log(key, _JOB[key].level);
      }

    }

    for (var key in result) {

      resultstr += "['" + result[key].join("','") + "'],\n"

    }

    console.log(resultstr);
  },


  createEquipShop: function () {

    var result = {
      'D': [],
      'C': [],
      'B': [],
      'A': [],
      'S': [],
      'SS': [],
    };

    var resultstr = "";

    for (var key in _EQUIP) {

      if (result[_EQUIP[key].qua]) {
        result[_EQUIP[key].qua].push(key);
      } else {
        console.log(key, _EQUIP[key].qua);
      }

    }

    for (var key in result) {

      resultstr += "['" + result[key].join("','") + "'],\n"

    }

    console.log(resultstr);
  },

  testMapOrder: function () {

  },

  openAllChapter: function () {

  },

  testJobEquip: function () {

    for (var key in _JOB) {
      var equipArr = _CROF.getEquipByJob(key);
      //if (equipArr.length < _JOB[key].equipType.length)
      console.log(key, _JOB[key].equipType, equipArr);
      

      if(
        _JOB[key].equipType.includes('坐骑')
        &&!_JOB[key].xw['qi']
      ){
      //  console.log(key,_JOB[key].level,"装备没有配对",equipArr);
      }
    }

  },

  showNpc: function (npc) {
    var npcarr = [];
    for (var i = 0; i < 3; i++) {
      window.gameData.hdlv = i;
      var tmpnpc = _ROF.createRole(npc);
      _ROF.recreateObjByHdlv(tmpnpc);
      npcarr.push(tmpnpc);
    }
    _MRDL.initUi(_MAP.node, { sence: _STYPE._FIGHTSENCE, roleArr: npcarr });

  },

  testEM: function () {

    for (var key in _EQUIPMODEL) {

      for (var lv in _EQUIPMODEL[key]) {

        for (var pos in _EQUIPMODEL[key][lv].attr) {

          if (!_M[_EQUIPMODEL[key][lv].attr[pos]]) {
            console.log(key, lv, pos, _EQUIPMODEL[key][lv].attr[pos], "不存在");
          }

        }

        for (var m in _EQUIPMODEL[key][lv].stone) {
          if (!_M[m]) {
            console.log(key, lv, pos, m, "不存在");
          }
        }

      }

    }

  },

  testAllJob: function () {
    var result = "";
    for (var key in _JOB) {

      result += (JOBHELPER.getJobDesc(key));

    }


    return result;
  },

  showAllSkill: function () {


    var result = "###########主动技能:\n";
    for (var key in _SKILL) {
      result += key + "\n";
      result += _IOF.getGoodsDetailStr(_IOF.createObjByName(key, null)) + "\n"
    }

    result += "###########被动技能:\n";
    for (var key in _SKILLBD) {
      result += key + "\n";
      result += _IOF.getGoodsDetailStr(_IOF.createObjByName(key, null))
    }

    return result;
  },

  testJobNmb: function () {

    var nmbmap = {};

    for (var key in _NPC) {
      if (_NPC[key].job) {
        if (!nmbmap[_NPC[key].job]) {
          nmbmap[_NPC[key].job] = 1;
        } else {
          nmbmap[_NPC[key].job]++;
        }
      }
    }

    console.log(nmbmap);
  },

  testNpcQua: function () {
    for (var key in _NPC) {
      if (
        _NPC[key].qua
        && (
          _NPC[key].qua != 'SS'
          && _NPC[key].qua != 'S'
          && _NPC[key].qua != 'A'
          && _NPC[key].qua != 'B'
          && _NPC[key].qua != 'C'
        )

      ) {
        console.log(_NPC[key]);
      }
    }
  },

  testAnimalsForLv: function () {
    var result = [];
    for (var key in _AREAARMY) {
      var animals = _AREAARMY[key].animals;
      for (var i = 0; i < animals.length; i++) {
        if (_NPC[animals[i]].ftype) {
          result.push({ map: key, name: animals[i], lv: _NPC[animals[i]].lv, ftype: _NPC[animals[i]].ftype, job: _NPC[animals[i]].job });
        }
      }
    }

    result.sort((a, b) => {
      var lva = a.lv;
      var lvb = b.lv;
      return lva - lvb;
    });

    //console.log(result);

    var resultstr = "";
    for (var i = 0; i < result.length; i++) {
      var tresult = result[i];
      var mapname = _MAPCONFIG[_MAPCONFIG[tresult.map].parent].name;
      resultstr += "等级:" + tresult.lv + " 地点:" + mapname + "-" + tresult.map + " 名称:" + tresult.name + " 类型:" + tresult.job + " 五行:" + tresult.ftype + "\n";
    }
    return resultstr;
  },


  testNpcSkill: function () {
    for (var key in _NPC) {

      var skill = _NPC[key].skill;

      if (skill && skill.length > 0) {

        for (var i = 0; i < skill.length; i++) {

          var skillname = skill[i];

          if (!_SKILL[skillname] && !_SKILLBD[skillname]) {

            console.log(key + " 技能：" + skillname + " 不存在")

          }

        }

      }

    }
  },


  signAllSkillNpc: function () {

    for (var key in _NPC) {
      if (window.gameData.realPos[key]) {
        if (_NPC[key].skill.length > 1) {
          window.gameData.realPos[key].sign = 1;
        } else {
          window.gameData.realPos[key].sign = 0;
        }
      }
    }

  },


  testAllItem: function () {
    for (var key in _FIGHTITEM) {

      _GAMEDATAHELPER.pushItem(_IOF.createObjByName(key, null));

    }
  },

  testNpcAlive: function () {

    var reg = /宅$/;
    var areaNpcMap = {};
    var cityNpcMap = {};

    for (var key in _AREAARMY) {
      var bossarr = _AREAARMY[key].boss;
      var guardarr = _AREAARMY[key].guard;
      for (var i = 0; i < bossarr.length; i++) {
        var boss = bossarr[i];
        areaNpcMap[boss] = key;
      }

      for (var i = 0; i < guardarr.length; i++) {
        var boss = guardarr[i];
        areaNpcMap[boss] = key;
      }
    }

    for (var key in _MAPCONFIG) {
      if (_MAPCONFIG[key].master) {
        for (var i = 0; i < _MAPCONFIG[key].master.length; i++) {
          var npc = _MAPCONFIG[key].master[i];
          if (cityNpcMap[npc] && npc != '') {
            console.log("城市npc重复出现:" + npc);
          }
          cityNpcMap[npc] = 1;
        }
      }

      if (reg.test(key)) {
        //console.log("####以宅结尾的配置:",key);
        if (!_MAPCONFIG[key].master || _MAPCONFIG[key].master.length != 1 || key != _MAPCONFIG[key].master[0] + "宅") {
          console.log("#####宅人员配置异常:", key, _MAPCONFIG[key]);
        }
      } else {
        //console.log("#####宅人员配置异常:",key);
      }
    }

    console.log("########野区或者守城中有而城内没有的npc:");
    for (var key in areaNpcMap) {
      if (!cityNpcMap[key]) {
        console.log(key);
      }
    }

    console.log("########城内有而野区中没有的npc:");
    for (var key in cityNpcMap) {
      if (!areaNpcMap[key]) {
        console.log(key);
      }
    }

    console.log("########野区和城内都没有的npc:");
    for (var key in _NPC) {
      if (_NPC[key].sex != null && !areaNpcMap[key] && !cityNpcMap[key]) {
        console.log(key);
      }
    }
  },

  openAllMap: function () {
    for (var key in _AREAARMY) _GAMEDATAHELPER.signMap(key);
  },

  testShopNmb: function () {

    for (var key in _SHOP) {

      if (_SHOP[key].sell.length > 24) {
        console.log(_SHOP[key].sell.length);
      }

    }

  },

  initShop: function () {

    var equipMap = {};
    var itemMap = {};
    var bookMap = {};
    var bookMap2 = {};
    //var quaArr = ["C","B","A","S","SS"];

    for (var key in _EQUIP) {

      var lv = _EQUIP[key].lv;
      if (!equipMap[lv]) {
        equipMap[lv] = [];
      }
      if (_EQUIP[key].pos != "spe")
        equipMap[lv].push(key);
    }

    for (var key in _FIGHTITEM) {

      var lv = _FIGHTITEM[key].lv;
      if (!itemMap[lv]) {
        itemMap[lv] = [];
      }

      itemMap[lv].push(key);
    }

    for (var key in _MAKE) {
      var itemname = _MAKE[key].item;
      if (!_EQUIP[itemname]) {
        console.log("制作书异常：", key);
      } else if (_EQUIP[itemname].pos != "spe") {
        var lv = _EQUIP[itemname].lv;
        if (!bookMap[lv]) {
          bookMap[lv] = [];
        }

        bookMap[lv].push(key);
      } else {
        var lv = _EQUIP[itemname].lv;
        if (!bookMap2[lv]) {
          bookMap2[lv] = [];
        }

        bookMap2[lv].push(key);
      }
    }

    var shopstr = "";
    var nmb = 0;
    for (var key in equipMap) {
      nmb++;
      shopstr += ("//" + key + "装备\n" + "'':{type:'equip',sell:['" + equipMap[key].join("','") + "']},\n");
    }

    for (var key in itemMap) {
      nmb++;
      shopstr += ("//" + key + "道具\n" + "'':{sell:['" + itemMap[key].join("','") + "']},\n");
    }

    for (var key in bookMap) {
      nmb++;
      shopstr += ("//" + key + "装备制作书\n" + "'':{sell:['" + bookMap[key].join("','") + "']},\n");
    }

    for (var key in bookMap2) {
      nmb++;
      shopstr += ("//" + key + "宝物制作书\n" + "'':{sell:['" + bookMap2[key].join("','") + "']},\n");
    }

    console.log(shopstr);
    console.log('总共' + nmb + "人");
  },

  findNoLogNpc: function () {
    console.log('一下npc没有记录:');
    for (var key in _NPC) { if (!window.gameData.realPos[key]) console.log(key); }
  },

  signAll: function () {

    for (var key in window.gameData.realPos) {
      window.gameData.realPos[key].sign = 1;
    }

  },

  testPrice: function () {

    var arr = ['fightItem', 'equipItem', 'materialItem', 'skillItem', 'specilItem', 'teamSkill'];
    for (var i = 0; i < arr.length; i++) {

      var arr1 = window.gameData[arr[i]];

      for (var j = 0; j < arr1.length; j++) {

        var goodsinfo = arr1[j];

        console.log(goodsinfo.type + ":" + _IOF.getGoodsPrice(goodsinfo))

      }

    }

  },

  testShop: function () {
    for (var key in _SHOP) {
      var shoparr = _SHOP[key].sell;
      for (var i = 0; i < shoparr.length; i++) {
        var itemname = shoparr[i];
        if (_EQUIP[itemname] && _EQUIP[itemname].pos == "spe") {
          console.log(key + " " + itemname);
        }
      }
    }
  },

  testImg: function () {

    for (var key in _NPC) {

      var tmpnpc = _NPC[key];
      var faceimg = _GRM.getFaceFrame(tmpnpc.face);
      var pfani = _GRM.getAttackFrame(tmpnpc.pf);
      if (
        faceimg._name == "问号"
      ) {
        console.log(key + '头像不存在:' + tmpnpc.face);
      }

      if (
        pfani.attack.length < 4
        || pfani.walk.length < 2
        || pfani.weak.length < 2
      ) {
        console.log(key + '形象不存在:' + tmpnpc.pf);
      }

    }

  },

  testAllConfig: function () {

    console.log('#######开始检查配置');

    for (var key in _AREAARMY) {
      var flag = false;
      for (var key2 in _MASTER) {
        if (_CU.isContain(_MASTER[key2].citys, key)) {
          flag = true;
        }
      }

      if (!flag) {
        console.log('野区 ' + key + " 没有归属....");
      }
    }



    for (var key in _NPC) {
      var npc = _NPC[key];
      var job = npc.job;
      var skill = npc.skill;
      if (job && !_JOB[job]) {
        console.log('角色' + key + ' 职业:' + job + " 不存在");
      }

      if (skill) {
        for (var i = 0; i < skill.length; i++) {
          if (!_SKILL[skill[i]] && !_SKILLBD[skill[i]]) {
            console.log('角色' + key + ' 技能:' + skill + " 不存在");
          }
        }
      }

    }

    for (var key in _AREAARMY) {

      var animals = _AREAARMY[key].animals;
      var boss = _AREAARMY[key].boss;
      var guard = _AREAARMY[key].guard;

      if (animals)
        for (var i = 0; i < animals.length; i++) {
          if (!_NPC[animals[i]]) {
            console.log('野区:' + key + " 动物:" + animals[i] + " 不存在");
          }
        }

      if (boss)
        for (var i = 0; i < boss.length; i++) {
          if (!_NPC[boss[i]]) {
            console.log('野区:' + key + " 角色:" + boss[i] + " 不存在");
          }
        }

      if (guard)
        for (var i = 0; i < guard.length; i++) {
          if (!_NPC[guard[i]]) {
            console.log('野区:' + key + " 守卫:" + guard[i] + " 不存在");
          }
        }
    }

    for (var key in _MAPCONFIG) {

      var masterArr = _MAPCONFIG[key].master;
      if (masterArr) {
        for (var i = 0; i < masterArr.length; i++) {
          if (!_NPC[masterArr[i]]) {
            console.log("地图 " + key + " " + masterArr[i] + " 不存在");
          }
        }
      }

    }

    for (var key in _SKILL) {
      if (!_SKILL[key].skilltype) {
        console.log('技能异常:', key, _SKILL[key]);
      }
    }

    console.log('#######检查配置结束');
  },

  addAll: function () {

    for (var key in _JOB) {
      window.gameData.playerTeamBack.push(_CROF.createJobRole(key, { dz: 100, npcname: key, noRandom: 1, attr: 100, lv: 1000 }));
    }

    for (var key in _MAKE) {
      _GAMEDATAHELPER.pushItem(_IOF.createObjByName(key, null));
    }

    for (var key in _SKILL) {
      _GAMEDATAHELPER.pushItem(_IOF.createObjByName(key, null));
    }

    for (var key in _SKILLBD) {
      _GAMEDATAHELPER.pushItem(_IOF.createObjByName(key, null));
    }

    for (var key in _EQUIP) {
      _GAMEDATAHELPER.pushItem(_IOF.createObjByName(key, null));
    }

    for (var key in _M) {
      _GAMEDATAHELPER.pushItem(_IOF.createObjByName(key, null));
    }

    for (var key in _SKILLTEAM) {

      _GAMEDATAHELPER.pushItem(_IOF.createObjByName(key, null));

    }

    for (var key in _FIGHTITEM) {
      _GAMEDATAHELPER.pushItem(_IOF.createObjByName(key, null));
    }
  },

  getFsxDes:function(key){

    for(var i=0;i<window._HELPERDOC.length;i++){
      if(key==window._HELPERDOC[i][0]){
          return _HELPERDOC[i][1];
      }
    }

    return null;
  },

  testfsx:function(){

    for(var key in _DICT){

      if(_TM.getFsxDes(_DICT[key])==null){
        console.log(_DICT[key]);
      }

    }

  },

  testRandomEquip:function(){
    for(var key in _EQUIP){
        var equip = _IOF.createEquip(key,{qua:'SS'})
        _MCFC.initEquipXw(equip);
        var xwarr = [];
        for(var xw in equip.xw){
            xwarr.push(xw);
        }
        console.log(xwarr);
    }

  },

  

  orderNpc:function(){

    var bossarr = [];
    var npcarr = [];
    for(var key in _NPC){
      var npcconf = _NPC[key];
      var total = npcconf.plv+npcconf.dlv+npcconf.ilv+npcconf.mlv+npcconf.hlv;
      if(npcconf.job!='无业'){
        if(!npcconf.isboss){
          npcarr.push({name:key,total:total,conf:npcconf});
        }else{
          bossarr.push({name:key,total:total,conf:npcconf});
        }
      }

    }

    npcarr.sort((a, b) => {
      var lva = a.total;
      var lvb = b.total;
      return lva - lvb;
    });

    //console.log(npcarr);

    bossarr.sort((a, b) => {
      var lva = a.total;
      var lvb = b.total;
      return lva - lvb;
    });

    //console.log(bossarr);
    var str = "#######################################小怪"+npcarr.length+"\n";
    for(var i=0;i<npcarr.length;i++){
      var tmpobj = npcarr[i].conf;
      str+=npcarr[i].name+" "+tmpobj.level+" "+tmpobj.race+" "+tmpobj.ftype+" "+tmpobj.job+" "+npcarr[i].total+"\n";
    }
    //console.log(str);
    str+= "#############################################boss"+bossarr.length+"\n";
    for(var i=0;i<bossarr.length;i++){
      var tmpobj = bossarr[i].conf;
      str+=bossarr[i].name+" "+tmpobj.level+" "+tmpobj.race+" "+tmpobj.ftype+" "+tmpobj.job+" "+bossarr[i].total+"\n";
    }
    console.log(str);
  },

  testTasklength:function(){
    var str = "";
    for(var key in _MAINTASK){
      var conf = _MAINTASK[key];
      if(conf.nexttask.length>1){
        //console.log(conf.nexttask,conf.nexttask.length);
        str+=conf.nexttask.join(',')+"\n";
      }
    }

    console.log(str);
  }

}